import cv2
import numpy as np

# 定义函数 falgs 是键盘控制键 shift ctrl 等
def mouse_callback(event, x, y, flags, userdata):
    print(event, x, y, flags, userdata)

# 函数执行
#mouse_callback(1, 100, 100, 16, '666')

# 创建窗口
cv2.namedWindow('mouse', cv2.WINDOW_NORMAL)
cv2.resizeWindow('mouse', 1280, 720)

# 设置鼠标回调
cv2.setMouseCallback('mouse', mouse_callback, "123")

img = np.zeros((720, 1280, 3), np.uint8)
while True:
    cv2.imshow('mouse', img)
    key = cv2.waitKey(1)
    if (key & 0xFF == ord('q')):
        break


cv2.destroyAllWindows()
